import './index.scss';
import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import Schart from 'vue-schart';
export default {
  name: 'findcount',
  components:{
    Schart
  },
  data () {
    return {
      qycTotal: [],
      donateTotal: [{otherMoneys: ''},{otherMoneys: ''},{otherMoneys: ''}],
      donatePercent: [],
      canvasId: 'myCanvas',
      type: 'pie',
      width: 300,
      height: 200,
      data: [
        {name: '助困', value: 0},
        {name: '助学', value: 0},
        {name: '助医', value: 0},
        {name: '其他', value: 0},
      ],
      options: {
        radius: 60,
        legendTop: -300,
        legendColor: '#ffffff',
        colorList: ['#e2a83d', '#8a3de3', '#218dce', '#42e53c']
      }
    }
  },
  mounted () {
    http.post(CONSTANT.DONATE_COUNT, {}, (res) => {
      console.log(res)
      if (res.code == 200) {
        // 饼状图比例数据
        // this.data[0].value = res.obj.donatePercent[0].poolPercent;
        // this.data[1].value = res.obj.donatePercent[0].studyPercent;
        // this.data[2].value = res.obj.donatePercent[0].medicinePercent;
        // this.data[3].value = res.obj.donatePercent[0].otherPercent;
        this.data = [
          {name: '助困', value: res.obj.donatePercent[0].pool},
          {name: '助学', value: res.obj.donatePercent[0].study},
          {name: '助医', value: res.obj.donatePercent[0].medicine},
          {name: '其他', value: res.obj.donatePercent[0].other},
        ],
        this.qycTotal = res.obj.qycTotal[0];
        this.donateTotal = res.obj.donateTotal;
        this.donatePercent = res.obj.donatePercent;

        this.$forceUpdate()
        console.log(this.data)
      }
    })
  },
  methods: {
    comeBack () {
      window.history.back()
    }
  }
}
